package com.tdtxdcxm.telmanagesys.slice;

import com.tdtxdcxm.telmanagesys.PeopleInfoConfig;
import com.tdtxdcxm.telmanagesys.ResourceTable;
import com.tdtxdcxm.telmanagesys.configcolor.BottomBarColor;
import com.tdtxdcxm.telmanagesys.itemdata.PeopleItem;
import com.tdtxdcxm.telmanagesys.provider.PeopleItemProvider;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.colors.RgbColor;
import ohos.agp.components.*;
import ohos.agp.components.element.Element;
import ohos.agp.components.element.ShapeElement;
import ohos.agp.render.ColorMatrix;
import ohos.agp.utils.Color;
import ohos.agp.utils.LayoutAlignment;
import ohos.agp.window.dialog.ToastDialog;

import java.util.ArrayList;
import java.util.List;

public class MainAbilitySlice extends AbilitySlice {
    private int idbut = -1;
    private int i = 0;

    private DirectionalLayout search_top_sublayout;
    private TextField search_tfd;
    private Button search_but;
    private DirectionalLayout edit_top_sublayout;
    private Button edit_deletebut,edit_resetbut,edit_okbut;
    private DirectionalLayout config_top_sublayout;
    private Button config_deletebut,config_resetbut,config_okbut;


    private DirectionalLayout people_listcontainer_sublayout;
    private ListContainer people_listcontainer;
    private List<PeopleItem> list = new ArrayList<>();
    private DirectionalLayout edit_area_rootdl;
    private Text edit_nametext;
    private Button edit_addtel_but,edit_addemail_but,edit_addwork_but,edit_addaddress_but;
    private TextField edit_nametfd,edit_teltfd,edit_emailtfd,edit_worktfd,edit_addresstfd;
    private DirectionalLayout config_area_rootdl;
    private RadioContainer config_radioContainer;
    private RadioButton bottombar_default,bottombar_dark,bottombar_light,bottombar_simple;


    private DirectionalLayout main_rootdl_ddl1;
    private DirectionalLayout main_rootdl_ddl2;
    private DirectionalLayout main_rootdl_ddl3;
    private Button ddl3_butpeople,ddl3_butedit,ddl3_butconfig;


    public void initAndLoadSearch(DirectionalLayout ddl1){
        ddl1.removeAllComponents();
        search_top_sublayout = (DirectionalLayout) LayoutScatter.getInstance(this).parse(ResourceTable.Layout_ability_search_topsublayout,null,false);
        search_tfd = (TextField) search_top_sublayout.findComponentById(ResourceTable.Id_search_tfd);
        search_but = (Button) search_top_sublayout.findComponentById(ResourceTable.Id_search_but);

        /*<*************************给输入框和搜索按钮设置监听器****************************/
        search_tfd.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {

            }
        });
        search_but.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                search_tfd.clearFocus();
                Intent intent = new Intent();
                intent.setParam("姓名",search_tfd.getText());
                present(new PersonDetailSlice(),intent);
            }
        });
        /****************************给输入框和搜索按钮设置监听器**************************>*/

        ddl1.addComponent(search_top_sublayout);
    }

    public void initAndLoadEditTop(DirectionalLayout ddl1){
        ddl1.removeAllComponents();
        edit_top_sublayout = (DirectionalLayout) LayoutScatter.getInstance(this).parse(ResourceTable.Layout_ability_edit_topsublayout,null,false);
        edit_deletebut = (Button) edit_top_sublayout.findComponentById(ResourceTable.Id_edit_deletebut);
        edit_resetbut = (Button) edit_top_sublayout.findComponentById(ResourceTable.Id_edit_resetbut);
        edit_okbut = (Button) edit_top_sublayout.findComponentById(ResourceTable.Id_edit_okbut);

        edit_okbut.setVisibility(Component.HIDE);

        /*<*************************给三个功能按钮设置监听器****************************/
        edit_deletebut.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                edit_nametfd.setText("");
                edit_nametfd.clearFocus();
                edit_nametext.setText("待输入");

                edit_teltfd.setText("");
                edit_teltfd.clearFocus();
                DirectionalLayout edit_telanother_rootdl = (DirectionalLayout) edit_area_rootdl.findComponentById(ResourceTable.Id_edit_telanother_rootdl);
                if(edit_telanother_rootdl != null){
                    ((TextField)edit_telanother_rootdl.findComponentById(ResourceTable.Id_edit_telanother_teltfd)).setText("");
                    ((TextField)edit_telanother_rootdl.findComponentById(ResourceTable.Id_edit_telanother_teltfd)).clearFocus();
                }

                edit_emailtfd.setText("");
                edit_emailtfd.clearFocus();
                DirectionalLayout edit_emailanother_rootdl = (DirectionalLayout) edit_area_rootdl.findComponentById(ResourceTable.Id_edit_emailanother_rootdl);
                if(edit_emailanother_rootdl != null){
                    ((TextField)edit_emailanother_rootdl.findComponentById(ResourceTable.Id_edit_emailanother_emailtfd)).setText("");
                    ((TextField)edit_emailanother_rootdl.findComponentById(ResourceTable.Id_edit_emailanother_emailtfd)).clearFocus();
                }

                edit_worktfd.setText("");
                edit_worktfd.clearFocus();
                DirectionalLayout edit_workanother_rootdl = (DirectionalLayout) edit_area_rootdl.findComponentById(ResourceTable.Id_edit_workanother_rootdl);
                if(edit_workanother_rootdl != null){
                    ((TextField) edit_workanother_rootdl.findComponentById(ResourceTable.Id_edit_workanother_worktfd)).setText("");
                    ((TextField) edit_workanother_rootdl.findComponentById(ResourceTable.Id_edit_workanother_worktfd)).clearFocus();
                }

                edit_addresstfd.setText("");
                edit_addresstfd.clearFocus();
                DirectionalLayout edit_addressanother_rootdl = (DirectionalLayout) edit_area_rootdl.findComponentById(ResourceTable.Id_edit_addressanother_rootdl);
                if(edit_addressanother_rootdl != null){
                    ((TextField) edit_addressanother_rootdl.findComponentById(ResourceTable.Id_edit_addressanother_addresstfd)).setText("");
                    ((TextField) edit_addressanother_rootdl.findComponentById(ResourceTable.Id_edit_addressanother_addresstfd)).clearFocus();
                }
                toastShow("已清空！");
            }
        });
        edit_resetbut.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                DirectionalLayout edit_telanother_rootdl = (DirectionalLayout) edit_area_rootdl.findComponentById(ResourceTable.Id_edit_telanother_rootdl);
                if(edit_telanother_rootdl != null){
                    edit_area_rootdl.removeComponent(edit_telanother_rootdl);
                    edit_addtel_but.setText("+");
                    edit_addtel_but.setTextColor(Color.GREEN);
                }
                DirectionalLayout edit_emailanother_rootdl = (DirectionalLayout) edit_area_rootdl.findComponentById(ResourceTable.Id_edit_emailanother_rootdl);
                if(edit_emailanother_rootdl != null){
                    edit_area_rootdl.removeComponent(edit_emailanother_rootdl);
                    edit_addemail_but.setText("+");
                    edit_addemail_but.setTextColor(Color.GREEN);
                }

                DirectionalLayout edit_workanother_rootdl = (DirectionalLayout) edit_area_rootdl.findComponentById(ResourceTable.Id_edit_workanother_rootdl);
                if(edit_workanother_rootdl != null){
                    edit_area_rootdl.removeComponent(edit_workanother_rootdl);
                    edit_addwork_but.setText("+");
                    edit_addwork_but.setTextColor(Color.GREEN);
                }

                DirectionalLayout edit_addressanother_rootdl = (DirectionalLayout) edit_area_rootdl.findComponentById(ResourceTable.Id_edit_addressanother_rootdl);
                if(edit_addressanother_rootdl != null){
                    edit_area_rootdl.removeComponent(edit_addressanother_rootdl);
                    edit_addaddress_but.setText("+");
                    edit_addaddress_but.setTextColor(Color.GREEN);
                }
                toastShow("已重置！");
            }
        });
        edit_okbut.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                String[] personinfo = new String[9];

                personinfo[0] = edit_nametfd.getText();

                personinfo[1] = edit_teltfd.getText();
                DirectionalLayout edit_telanother_rootdl = (DirectionalLayout) edit_area_rootdl.findComponentById(ResourceTable.Id_edit_telanother_rootdl);
                if(edit_telanother_rootdl != null){
                    personinfo[2] = ((TextField)edit_telanother_rootdl.findComponentById(ResourceTable.Id_edit_telanother_teltfd)).getText();
                }
                else{
                    personinfo[2] = "";
                }

                personinfo[3] = edit_emailtfd.getText();
                DirectionalLayout edit_emailanother_rootdl = (DirectionalLayout) edit_area_rootdl.findComponentById(ResourceTable.Id_edit_emailanother_rootdl);
                if(edit_emailanother_rootdl != null){
                    personinfo[4] = ((TextField)edit_emailanother_rootdl.findComponentById(ResourceTable.Id_edit_emailanother_emailtfd)).getText();
                }
                else{
                    personinfo[4] = "";
                }

                personinfo[5] = edit_worktfd.getText();
                DirectionalLayout edit_workanother_rootdl = (DirectionalLayout) edit_area_rootdl.findComponentById(ResourceTable.Id_edit_workanother_rootdl);
                if(edit_workanother_rootdl != null){
                    personinfo[6] = ((TextField) edit_workanother_rootdl.findComponentById(ResourceTable.Id_edit_workanother_worktfd)).getText();
                }
                else{
                    personinfo[6] = "";
                }

                personinfo[7] = edit_addresstfd.getText();
                DirectionalLayout edit_addressanother_rootdl = (DirectionalLayout) edit_area_rootdl.findComponentById(ResourceTable.Id_edit_addressanother_rootdl);
                if(edit_addressanother_rootdl != null){
                    personinfo[8] = ((TextField) edit_addressanother_rootdl.findComponentById(ResourceTable.Id_edit_addressanother_addresstfd)).getText();
                }
                else{
                    personinfo[8] = "";
                }
                PeopleInfoConfig.writeData(MainAbilitySlice.this.getContext(),personinfo);

                ddl3_butpeople.getClickedListener().onClick(ddl3_butpeople);
            }
        });
        /***************************给三个功能按钮设置监听器**************************>*/

        ddl1.addComponent(edit_top_sublayout);

    }

    public void initAndLoadConfigTop(DirectionalLayout ddl1){
        ddl1.removeAllComponents();
        config_top_sublayout = (DirectionalLayout) LayoutScatter.getInstance(this).parse(ResourceTable.Layout_ability_config_topsublayout,null,false);
        config_resetbut = (Button) config_top_sublayout.findComponentById(ResourceTable.Id_config_resetbut);
        config_okbut = (Button) config_top_sublayout.findComponentById(ResourceTable.Id_config_okbut);

        /*<*****************************给三个功能按钮设置监听器*************************************/
        config_resetbut.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                RadioContainer radioContainer = (RadioContainer) main_rootdl_ddl2.findComponentById(ResourceTable.Id_config_radioContainer);
                if(radioContainer != null){
                    radioContainer.mark(0);
                    BottomBarColor.setBottomBarColor(main_rootdl_ddl3,MainAbilitySlice.this.i);
                }
            }
        });
        config_okbut.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                BottomBarColor.setBottomBarColor(main_rootdl_ddl3,MainAbilitySlice.this.i);
                toastShow("已经设置：第"+(MainAbilitySlice.this.i+1)+"种主题！");
            }
        });
        /******************************给三个功能按钮设置监听器***********************************>*/

        ddl1.addComponent(config_top_sublayout);

    }

    public void toastShow(String s){
        ToastDialog toastDialog = new ToastDialog(this.getContext());
        toastDialog.setText(s);
        toastDialog.setTransparent(true);
        toastDialog.setDuration(500);
        toastDialog.setAlignment(LayoutAlignment.CENTER);
        toastDialog.show();
    }

    public void installListContainer(DirectionalLayout ddl2){
        System.out.println("开始装载listcontainer!！");
        ddl2.removeAllComponents();
        people_listcontainer_sublayout = (DirectionalLayout) LayoutScatter.getInstance(this).parse(ResourceTable.Layout_ability_people_listcontainerlayout,null,false);
        people_listcontainer = (ListContainer) people_listcontainer_sublayout.findComponentById(ResourceTable.Id_people_listcontainer);

        ddl2.addComponent(people_listcontainer_sublayout);
    }
    public void initListContainer(){
        System.out.println("开始读出数据！");
        PeopleInfoConfig.readData(this.getContext(),list);
        PeopleItemProvider peopleItemProvider = new PeopleItemProvider(list,this);
        people_listcontainer.setItemProvider(peopleItemProvider);

        people_listcontainer.setItemClickedListener(new ListContainer.ItemClickedListener() {
            @Override
            public void onItemClicked(ListContainer listContainer, Component component, int i, long l) {
                Text item_text = (Text) component.findComponentById(ResourceTable.Id_item_text);

                if(item_text.getText().equals("请添加联系人") == false){
                    Intent intent = new Intent();
                    intent.setParam("姓名",item_text.getText());
                    present(new PersonDetailSlice(),intent);
                }
                else{
                    toastShow("通讯录无联系人信息！");
                }
            }
        });
        people_listcontainer.setItemLongClickedListener(new ListContainer.ItemLongClickedListener() {
            @Override
            public boolean onItemLongClicked(ListContainer listContainer, Component component, int i, long l) {
                Text item_text = (Text) component.findComponentById(ResourceTable.Id_item_text);
                item_text.setTextColor(Color.RED);
                PeopleInfoConfig.deleteData(MainAbilitySlice.this.getContext(),item_text.getText());
                PeopleInfoConfig.readData(MainAbilitySlice.this.getContext(),list);
                peopleItemProvider.notifyDataChanged();

                return true;
            }
        });
    }

    public void installEditArea(DirectionalLayout ddl2){
        ddl2.removeAllComponents();
        edit_area_rootdl = (DirectionalLayout) LayoutScatter.getInstance(this).parse(ResourceTable.Layout_ability_edit,null,false);
        edit_nametext = (Text) edit_area_rootdl.findComponentById(ResourceTable.Id_edit_nametext);
        edit_addtel_but = (Button) edit_area_rootdl.findComponentById(ResourceTable.Id_edit_addtel_but);
        edit_addemail_but = (Button) edit_area_rootdl.findComponentById(ResourceTable.Id_edit_addemail_but);
        edit_addwork_but = (Button) edit_area_rootdl.findComponentById(ResourceTable.Id_edit_addwork_but);
        edit_addaddress_but = (Button) edit_area_rootdl.findComponentById(ResourceTable.Id_edit_addaddress_but);

        edit_nametfd = (TextField) edit_area_rootdl.findComponentById(ResourceTable.Id_edit_nametfd);
        edit_teltfd = (TextField) edit_area_rootdl.findComponentById(ResourceTable.Id_edit_teltfd);
        edit_emailtfd = (TextField) edit_area_rootdl.findComponentById(ResourceTable.Id_edit_emailtfd);
        edit_worktfd = (TextField) edit_area_rootdl.findComponentById(ResourceTable.Id_edit_worktfd);
        edit_addresstfd = (TextField) edit_area_rootdl.findComponentById(ResourceTable.Id_edit_addresstfd);
        /*<**********************************给输入姓名的文本框设置文本监视***********************************/
        edit_nametfd.addTextObserver(new Text.TextObserver() {
            @Override
            public void onTextUpdated(String s, int i, int i1, int i2) {
                edit_nametext.setText(s);
                if(s.equals("")){
                    edit_okbut.setVisibility(Component.HIDE);
                    edit_okbut.setText("确认");
                }
                else{
                    edit_okbut.setVisibility(Component.VISIBLE);
                }
            }
        });
        /************************************给输入姓名的文本框设置文本监视*********************************>*/

        /*<****************************给四个添加按钮设置监听器******************************************/
        edit_addtel_but.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                if(edit_addtel_but.getText().equals("-")){
                    DirectionalLayout edit_telanother_rootdl = (DirectionalLayout) edit_area_rootdl.findComponentById(ResourceTable.Id_edit_telanother_rootdl);
                    edit_area_rootdl.removeComponent(edit_telanother_rootdl);
                    edit_addtel_but.setText("+");
                    edit_addtel_but.setTextColor(Color.GREEN);
                    return;
                }
                DirectionalLayout edit_tel_dlyt = (DirectionalLayout) findComponentById(ResourceTable.Id_edit_tel_dlyt);
                DirectionalLayout edit_telanother_rootdl = (DirectionalLayout) LayoutScatter.getInstance(MainAbilitySlice.this).parse(ResourceTable.Layout_ability_edit_telsublayout,null,false);

                int i = edit_area_rootdl.getChildIndex(edit_tel_dlyt);
                System.out.println("edit_area_rootdl.getChildCount()-->"+edit_area_rootdl.getChildCount());

                edit_area_rootdl.addComponent(edit_telanother_rootdl,i+1);

                edit_addtel_but.setText("-");
                edit_addtel_but.setTextColor(Color.RED);
            }
        });
        edit_addemail_but.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                if(edit_addemail_but.getText().equals("-")){
                    DirectionalLayout edit_emailanother_rootdl = (DirectionalLayout) edit_area_rootdl.findComponentById(ResourceTable.Id_edit_emailanother_rootdl);
                    edit_area_rootdl.removeComponent(edit_emailanother_rootdl);
                    edit_addemail_but.setText("+");
                    edit_addemail_but.setTextColor(Color.GREEN);
                    return;
                }
                DirectionalLayout edit_email_dlyt = (DirectionalLayout) findComponentById(ResourceTable.Id_edit_email_dlyt);
                DirectionalLayout edit_emailanother_rootdl = (DirectionalLayout) LayoutScatter.getInstance(MainAbilitySlice.this).parse(ResourceTable.Layout_ability_edit_emailsublayout,null,false);

                int i = edit_area_rootdl.getChildIndex(edit_email_dlyt);
                System.out.println("edit_area_rootdl.getChildCount()-->"+edit_area_rootdl.getChildCount());

                edit_area_rootdl.addComponent(edit_emailanother_rootdl,i+1);

                edit_addemail_but.setText("-");
                edit_addemail_but.setTextColor(Color.RED);
            }
        });
        edit_addwork_but.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                if(edit_addwork_but.getText().equals("-")){
                    DirectionalLayout edit_workanother_rootdl = (DirectionalLayout) edit_area_rootdl.findComponentById(ResourceTable.Id_edit_workanother_rootdl);
                    edit_area_rootdl.removeComponent(edit_workanother_rootdl);
                    edit_addwork_but.setText("+");
                    edit_addwork_but.setTextColor(Color.GREEN);
                    return;
                }
                DirectionalLayout edit_work_dlyt = (DirectionalLayout) findComponentById(ResourceTable.Id_edit_work_dlyt);
                DirectionalLayout edit_workanother_rootdl = (DirectionalLayout) LayoutScatter.getInstance(MainAbilitySlice.this).parse(ResourceTable.Layout_ability_edit_worksublayout,null,false);

                int i = edit_area_rootdl.getChildIndex(edit_work_dlyt);
                System.out.println("edit_area_rootdl.getChildCount()-->"+edit_area_rootdl.getChildCount());

                edit_area_rootdl.addComponent(edit_workanother_rootdl,i+1);

                edit_addwork_but.setText("-");
                edit_addwork_but.setTextColor(Color.RED);
            }
        });
        edit_addaddress_but.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                if(edit_addaddress_but.getText().equals("-")){
                    DirectionalLayout edit_addressanother_rootdl = (DirectionalLayout) edit_area_rootdl.findComponentById(ResourceTable.Id_edit_addressanother_rootdl);
                    edit_area_rootdl.removeComponent(edit_addressanother_rootdl);
                    edit_addaddress_but.setText("+");
                    edit_addaddress_but.setTextColor(Color.GREEN);
                    return;
                }
                DirectionalLayout edit_address_dlyt = (DirectionalLayout) findComponentById(ResourceTable.Id_edit_address_dlyt);
                DirectionalLayout edit_addressanother_rootdl = (DirectionalLayout) LayoutScatter.getInstance(MainAbilitySlice.this).parse(ResourceTable.Layout_ability_edit_addresssublayout,null,false);

                int i = edit_area_rootdl.getChildIndex(edit_address_dlyt);
                System.out.println("edit_area_rootdl.getChildCount()-->"+edit_area_rootdl.getChildCount());

                edit_area_rootdl.addComponent(edit_addressanother_rootdl,i+1);

                edit_addaddress_but.setText("-");
                edit_addaddress_but.setTextColor(Color.RED);
            }
        });
        /*****************************给四个添加按钮设置监听器****************************************>*/

        ddl2.addComponent(edit_area_rootdl);
    }

    public void installConfigArea(DirectionalLayout ddl2){
        ddl2.removeAllComponents();
        config_area_rootdl = (DirectionalLayout) LayoutScatter.getInstance(this).parse(ResourceTable.Layout_ability_config,null,false);
        config_radioContainer = (RadioContainer) config_area_rootdl.findComponentById(ResourceTable.Id_config_radioContainer);
        bottombar_default = (RadioButton) config_area_rootdl.findComponentById(ResourceTable.Id_bottombar_default);
        bottombar_dark = (RadioButton) config_area_rootdl.findComponentById(ResourceTable.Id_bottombar_dark);
        bottombar_light = (RadioButton) config_area_rootdl.findComponentById(ResourceTable.Id_bottombar_light);
        bottombar_simple = (RadioButton) config_area_rootdl.findComponentById(ResourceTable.Id_bottombar_simple);
        config_radioContainer.mark(MainAbilitySlice.this.i);
        config_radioContainer.setMarkChangedListener(new RadioContainer.CheckedStateChangedListener() {
            @Override
            public void onCheckedChanged(RadioContainer radioContainer, int i) {
                switch (i){
                    case 0:
                        toastShow("选择："+bottombar_default.getText());
                        MainAbilitySlice.this.i = i;
                        break;
                    case 1:
                        toastShow("选择："+bottombar_dark.getText());
                        MainAbilitySlice.this.i = i;
                        break;
                    case 2:
                        toastShow("选择："+bottombar_light.getText());
                        MainAbilitySlice.this.i = i;
                        break;
                    case 3:
                        toastShow("选择："+bottombar_simple.getText());
                        MainAbilitySlice.this.i = i;
                        break;
                    default:
                        break;
                }
            }
        });
        ddl2.addComponent(config_area_rootdl);
    }

    public void initMASliceComponents(){
        main_rootdl_ddl1 = (DirectionalLayout) findComponentById(ResourceTable.Id_main_rootdl_ddl1);
        main_rootdl_ddl2 = (DirectionalLayout) findComponentById(ResourceTable.Id_main_rootdl_ddl2);
        main_rootdl_ddl3 = (DirectionalLayout) findComponentById(ResourceTable.Id_main_rootdl_ddl3);
        ddl3_butpeople = (Button) findComponentById(ResourceTable.Id_ddl3_butpeople);

        main_rootdl_ddl3.setBackground(BottomBarColor.defaultShapeElement());


        ddl3_butpeople.getBackgroundElement().setColorMatrix(new ColorMatrix(BottomBarColor.onclickfloats));
        idbut = ResourceTable.Id_ddl3_butpeople;


        ddl3_butedit = (Button) findComponentById(ResourceTable.Id_ddl3_butedit);
        ddl3_butconfig = (Button) findComponentById(ResourceTable.Id_ddl3_butconfig);

        /*<*************************给三个导航按钮监听器****************************/
        ddl3_butpeople.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                if(idbut != ddl3_butpeople.getId()) {
                    Button button = (Button) findComponentById(idbut);
                    button.getBackgroundElement().setColorMatrix(new ColorMatrix(BottomBarColor.simplecolor));


                    ddl3_butpeople.getBackgroundElement().setColorMatrix(new ColorMatrix(BottomBarColor.onclickfloats));
                    idbut = ddl3_butpeople.getId();
                    initAndLoadSearch(main_rootdl_ddl1);
                    installListContainer(main_rootdl_ddl2);
                    initListContainer();
                }
            }
        });
        ddl3_butedit.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                if(idbut != ddl3_butedit.getId()) {
                    Button button = (Button) findComponentById(idbut);
                    button.getBackgroundElement().setColorMatrix(new ColorMatrix(BottomBarColor.simplecolor));


                    ddl3_butedit.getBackgroundElement().setColorMatrix(new ColorMatrix(BottomBarColor.onclickfloats));
                    idbut = ddl3_butedit.getId();
                    initAndLoadEditTop(main_rootdl_ddl1);
                    installEditArea(main_rootdl_ddl2);
                }
            }
        });
        ddl3_butconfig.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                if(idbut != ddl3_butconfig.getId()) {
                    Button button = (Button) findComponentById(idbut);
                    button.getBackgroundElement().setColorMatrix(new ColorMatrix(BottomBarColor.simplecolor));


                    ddl3_butconfig.getBackgroundElement().setColorMatrix(new ColorMatrix(BottomBarColor.onclickfloats));
                    idbut = ddl3_butconfig.getId();
                    initAndLoadConfigTop(main_rootdl_ddl1);
                    installConfigArea(main_rootdl_ddl2);
                }
            }
        });
        /***************************给三个导航按钮监听器**************************>*/

    }

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);
        System.out.println("开始了-----》》》》》》");
        initMASliceComponents();
        initAndLoadSearch(main_rootdl_ddl1);
        installListContainer(main_rootdl_ddl2);
        initListContainer();
    }

    @Override
    protected void onInactive() {
        super.onInactive();
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }

    @Override
    protected void onBackground() {
        super.onBackground();
    }

    @Override
    protected void onStop() {
        super.onStop();
    }
}